<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <br/>
    <h3>C++Dll</h3>
    <input v-model="cjj.valA" type="text"/>
    <input v-model="cjj.valB" type="text"/>={{cjj.val}}
    <button @click="CalcButton()">调用C++ dll计算</button>
  </div>
</template>

<script>
// @ is an alias to /src
const ffi = require('ffi-napi');
const myDLL =  ffi.Library('resources/dll/MyDLL.dll', {
  Add: ['float', ['float', 'float']],
  Hello: ['string', []],
  StrLength: ['int', ['string']]
});
export default {
  name: 'Home',
  components: {
  },
  data(){
    return{
      list: [],
      cjj:{valA:1,valB:5,val:''}
    }
  },
  created() {
    console.log('fii.Library -------');
    console.log('fii.Library result:', myDLL);
    console.log('fii.Library Hello :', myDLL.Hello());
  },
  methods:{
  //c++测试
    CalcButton(){
      const result = myDLL.Add(parseFloat(this.cjj.valA), parseFloat(this.cjj.valB));
      this.cjj.val=result.toString()
    }
  }

}
</script>
